package com.fruit.service.redis;

import redis.clients.jedis.Jedis;
import java.util.Map;

public interface JedisUtil {

	/**
	 * 加锁
	 * @return
	 * @author admin
	 * @version 2017
	 */
	public boolean lock(String key, long timeout, int expire);
	
	
	/**
	 * 解锁
	 * 
	 * @author admin
	 * @version 2017
	 */
	public void unlock(String key);
	
	/**
	 * 获取redis值
	 * @param key
	 * @return
	 * @author admin
	 * @version 2017
	 */
	public String get(String key);
	
	/**
	 * 设置值
	 * @param key
	 * @param value
	 * @author admin
	 * @version 2017
	 */
	public void set(String key, String value);
	
	/**
	 * 设置值
	 * @param key
	 * @param value
	 * @param expire
	 * @author admin
	 * @version 2017
	 */
	public void set(String key, String value, int expire) throws Exception;
	
	/**
	 * 获取redis
	 * @return
	 * @author admin
	 * @version 2017
	 */
	public Jedis getRedis();
	
	/**
	 * 删除redis
	 * @param key
	 * @author admin
	 * @version 2017
	 */
	public void del(String key);
	
	/**
	 * 设置失效时间
	 * @param expire
	 * @author admin
	 * @version 2017
	 */
	public void expire(String key, int expire);
	
	/**
	 * 判断是否存在
	 * @param key
	 * @author admin
	 * @version 2017
	 */
	public boolean exists(String key) throws Exception;
	
	/**
	 * 获取MAP集合
	 * @param key
	 * @return
	 * @throws Exception
	 * @author admin
	 * @version 2017
	 */
	public Map<String, String> hgetAll(String key);
	
	/**
	 * 删除MAP子值
	 * @param key
	 * @param fields
	 * @return
	 * @author admin
	 * @version 2017
	 */
	public Long hdel(final String key, final String... fields);
	
	/**
	 * 往HAMAP 中设置值
	 * @param key
	 * @param field
	 * @param value
	 * @return
	 * @author admin
	 * @version 2017
	 */
	public Long hset(final String key, final String field, final String value);
}
